import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    sid: '',
    isLogin: false,
    userInfo: {},
    menuId: 0,
    token: ''
  },
  mutations: {
    setSid (state, value) {
      state.sid = value
    },
    setToken (state, value) {
      state.token = value
      localStorage.setItem('setToken', JSON.stringify(value))
    },
    // 设置用户信息
    setUserInfo (state, value) {
      state.userInfo = value
      localStorage.setItem('setUserInfo', JSON.stringify(value))
    },
    // 保存登录状态
    setIsLogin (state, value) {
      state.isLogin = value
    },
    setMenuId (state, value) {
      state.menuId = value
    }
  },
  actions: {

  }
})
